﻿<ribbon:RibbonWindow x:Class="SimpleHIDTestApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
        xmlns:WPF="clr-namespace:SimpleHIDTestApplication.WPF" Title="Simple HID Library Test Application"
        Height="700"
        Width="900"
        ResizeMode="CanResizeWithGrip"
        DataContext="{Binding Main, Source={StaticResource Locator}}"
                     Background="#FFE0EAF6" Icon="USB.ico">

  <Window.Resources>

    <DataTemplate x:Key="VidPidTemplate">
      <StackPanel Orientation="Horizontal">
        <StackPanel Margin="2" Orientation="Vertical">
          <TextBlock FontSize="8" Text="{Binding Vid, StringFormat=Vid: 0x{0:X4}}" />
          <TextBlock FontSize="8" Text="{Binding Pid, StringFormat=Pid: 0x{0:X4}}" />
        </StackPanel>
        <TextBlock FontSize="16" Margin="2" FontWeight="Bold" Text="{Binding ProductString}" />
      </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="buttonTemplate" DataType="ButtonItem">
      <StackPanel Orientation="Horizontal">
        <TextBlock Text="Button: " />
        <TextBlock Text="{Binding TopLevelUsagePage, StringFormat=TopLevelUsagePage: 0x{0:X4}}" />
        <TextBlock Text=" " />
        <TextBlock Text="{Binding ReportId, StringFormat=ReportId: 0x{0:X4}}" />
        <TextBlock Text=" " />
        <TextBlock Text="{Binding UsagePage, StringFormat=UsagePage: 0x{0:X4}}" />
        <TextBlock Text=" " />
        <TextBlock Text="{Binding Usage, StringFormat=Usage: 0x{0:X4}}" />
      </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="rangeTemplate" DataType="ButtonRangeItem">
      <StackPanel Orientation="Horizontal">
        <TextBlock Text="Range: " />
        <TextBlock Text="{Binding TopLevelUsagePage, StringFormat=TopLevelUsagePage: 0x{0:X4}}" />
        <TextBlock Text=" " />
        <TextBlock Text="{Binding ReportId, StringFormat=ReportId: 0x{0:X4}}" />
        <TextBlock Text=" " />
        <TextBlock Text="{Binding UsagePage, StringFormat=UsagePage: 0x{0:X4}}" />
        <TextBlock Text=" " />
        <TextBlock Text="{Binding UsageMin, StringFormat=UsageMin: 0x{0:X4}}" />
        <TextBlock Text=" " />
        <TextBlock Text="{Binding UsageMax, StringFormat=UsageMax: 0x{0:X4}}" />
      </StackPanel>
    </DataTemplate>

    <WPF:HIDTemplateSelector 
     ButtonTemplate="{StaticResource buttonTemplate}"
     RangeTemplate="{StaticResource rangeTemplate}" 
     x:Key="hidTemplateSelector" />

  </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <ribbon:Ribbon x:Name="Ribbon" Grid.Row="0">

        <ribbon:Ribbon.HelpPaneContent>
          <StackPanel Orientation="Horizontal">
            <ribbon:RibbonButton SmallImageSource="Resources\Help.png"  ToolTipTitle="Help" ToolTipImageSource="Resources\Help.png" ToolTipDescription="I need help!" KeyTipService.KeyTip="P"/>
          </StackPanel>
        </ribbon:Ribbon.HelpPaneContent>


        <ribbon:Ribbon.ApplicationMenu>
          <ribbon:RibbonApplicationMenu KeyTipService.KeyTip="F" SmallImageSource="Resources\FileIcon.png">
            <ribbon:RibbonApplicationMenuItem Header="E_xit" ImageSource="Resources\Exit.png" />
          </ribbon:RibbonApplicationMenu>
        </ribbon:Ribbon.ApplicationMenu>

        <ribbon:RibbonTab x:Name="HomeTab" Header="Home" KeyTipService.KeyTip="H">
          <ribbon:RibbonGroup Header="HID Device List">
            <ribbon:RibbonButton Label="Refresh" 
                               Command="{Binding UpdateButtonCommand}" CommandParameter="1"
                               LargeImageSource="Resources/Refresh.png" KeyTipService.KeyTip="T"
                               ToolTipTitle="TODO"
                               ToolTipDescription="TODO TODO TODO"                               
                               ToolTipImageSource="Resources\RefreshToolTip.png"
                               />

            <ListBox Grid.Row="2" Width="250" Height="64"  ItemsSource="{Binding HIDUSBDevices}"
         IsSynchronizedWithCurrentItem="true" SelectedItem="{Binding SelectedHIDUSBDevice}" ItemTemplate="{StaticResource VidPidTemplate}" />

            
            

          </ribbon:RibbonGroup>


          <ribbon:RibbonGroup Header="@" SmallImageSource="Resources\GoTo.png">
            <ribbon:RibbonButton SmallImageSource="Resources\GoTo.png" Label="Visit Web-site" 
                               KeyTipService.KeyTip="W"
                               ToolTipTitle="Codeplex project site"
                               ToolTipDescription="Allows you to go to the Codeplex project site"/>
          </ribbon:RibbonGroup>

        </ribbon:RibbonTab>
      </ribbon:Ribbon>

        </Grid>

        <Grid Grid.Row="1">

    <Grid.ColumnDefinitions>
      <ColumnDefinition/>
      <ColumnDefinition/>
    </Grid.ColumnDefinitions>

    <Grid Grid.Column="0" Margin="10">

      <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
          <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>


        <TextBlock Grid.Column="0" Grid.Row="0">HidCaps:</TextBlock>
          <ListBox Grid.Column="0" Grid.Row="1" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding HidCaps}" ItemTemplateSelector="{StaticResource hidTemplateSelector}" >
          <ListBox.ItemContainerStyle>
            <Style TargetType="{x:Type ListBoxItem}">
              <Setter Property="Focusable" Value="False"/>
            </Style>
          </ListBox.ItemContainerStyle>
        </ListBox>

        <Expander Header="InputButtonCaps" Grid.Column="0" Grid.Row="2" IsExpanded="{Binding ExpandInputButtonCaps}">
        <ListBox Height="150" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding ButtonInputCaps}" ItemTemplateSelector="{StaticResource hidTemplateSelector}" />
      </Expander>

      <Expander Header="InputValueCaps" Grid.Column="0" Grid.Row="3" IsExpanded="{Binding ExpandInputValueCaps}">
        <ListBox Height="150" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding ValueInputCaps}">
        </ListBox>
      </Expander>

      <Expander Header="OutputButtonCaps" Grid.Column="0" Grid.Row="4" IsExpanded="{Binding ExpandOutputButtonCaps}">
        <ListBox Height="150" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding ButtonOutputCaps}" ItemTemplateSelector="{StaticResource hidTemplateSelector}" />
      </Expander>

      <Expander Header="OutputValueCaps" Grid.Column="0" Grid.Row="5" IsExpanded="{Binding ExpandOutputValueCaps}">
        <ListBox Height="150" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding ValueOutputCaps}">
        </ListBox>
      </Expander>

      <Expander Header="FeatureButtonCaps" Grid.Column="0" Grid.Row="6" IsExpanded="{Binding ExpandFeatureButtonCaps}">
        <ListBox Height="150" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding ButtonFeatureCaps}" ItemTemplateSelector="{StaticResource hidTemplateSelector}" />
      </Expander>

      <Expander Header="FeatureValueCaps" Grid.Column="0" Grid.Row="7" IsExpanded="{Binding ExpandFeatureValueCaps}">
        <ListBox Height="150" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding ValueFeatureCaps}">
        </ListBox>
      </Expander>

    </Grid>

    <Grid Grid.Column="1" Margin="10">

      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>

      <StackPanel Grid.Column="0" Grid.Row="0">
        <TextBlock Text="Output Report:"/>
        <StackPanel Orientation="Horizontal">
          <ComboBox Width="200" ItemsSource="{Binding ButtonOutputCaps}" SelectedValue="{Binding OutputReportItem}" ItemTemplateSelector="{StaticResource hidTemplateSelector}"></ComboBox>
            <ComboBox SelectedIndex="0">
              <ComboBoxItem>True</ComboBoxItem>
              <ComboBoxItem>False</ComboBoxItem>
            </ComboBox>
              <Button Command="{Binding AddButtonCommand, Mode=OneWay}" Content="Add" />
        </StackPanel>
        <ListBox Height="100" ItemsSource="{Binding Report}" IsSynchronizedWithCurrentItem="true" ItemTemplateSelector="{StaticResource hidTemplateSelector}" />
        <Button HorizontalAlignment="Left" Command="{Binding SendReportButtonCommand, Mode=OneWay}" Content="Send Report" />
      </StackPanel>


      <StackPanel Grid.Column="0" Grid.Row="1">
          <StackPanel>
          <TextBlock Text="Input Report:" Margin="0,10,0,0"/>
          <ListView Height="200" ItemsSource="{Binding Input}" ItemTemplateSelector="{StaticResource hidTemplateSelector}">
          </ListView>
          </StackPanel>
      </StackPanel>

    </Grid>
  </Grid>
    </Grid>

</ribbon:RibbonWindow>
